//
//  PlayTableViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/5.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "PlayTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation PlayTableViewCell
-(void)dealloc
{
    [_backImageView release];
    [_pictureImageView release];
    [_userImageView release];
    [_titleLabel release];
    [_timeLabel release];
    [_typeLabel release];
    [_moneyLabel release];
    [_playList release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _backImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_backImageView];
    [_backImageView release];
    _pictureImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_pictureImageView];
    [_pictureImageView release];
    _userImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_userImageView];
    [_userImageView release];
    _titleLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_titleLabel];
    [_titleLabel release];
    _timeLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_timeLabel];
    [_timeLabel release];
    _typeLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_typeLabel];
    [_typeLabel release];
    _moneyLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_moneyLabel];
    [_moneyLabel release];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _backImageView.frame = CGRectMake(10 * W, 10 * H, self.contentView.frame.size.width - 20 * W, self.contentView.frame.size.height - 10 * H);
    _backImageView.layer.masksToBounds = YES;
    _backImageView.layer.cornerRadius = 5;
    _backImageView.backgroundColor = [UIColor colorWithRed:0.56 green:0.53 blue:0.93 alpha:1];
    _pictureImageView.frame = CGRectMake(0, 0, _backImageView.frame.size.width, 220 * H);
    _userImageView.frame = CGRectMake(250 * W, 190 * H, 60 * W, 60 * W);
    _titleLabel.frame = CGRectMake(_pictureImageView.frame.origin.x + 10 * W, _pictureImageView.frame.origin.y + _pictureImageView.frame.size.height + 10 * H, 200 * W, 60 * H);
    _timeLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15 * H, _backImageView.frame.size.width - 20 * W, 20 * H);
    _typeLabel.frame = CGRectMake(_timeLabel.frame.origin.x, _timeLabel.frame.origin.y + _timeLabel.frame.size.height + 15 * H, 200 * W, 20 * H);
    _moneyLabel.frame = CGRectMake(_userImageView.frame.origin.x, _typeLabel.frame.origin.y, 80 * W, 40 * H);
    
}
-(void)setPlayList:(PlayList *)playList
{
    if (_playList != playList) {
        [_playList release];
        _playList = [playList retain];
    }
    [_pictureImageView sd_setImageWithURL:[NSURL URLWithString:_playList.title_page]placeholderImage:[UIImage imageNamed:@"dengdai"]];
    [_userImageView sd_setImageWithURL:[NSURL URLWithString:[_playList.user objectForKey:@"avatar_l"]]placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _userImageView.layer.cornerRadius = _userImageView.frame.size.width / 2;
    _userImageView.layer.masksToBounds = YES;
    _userImageView.layer.borderWidth = 2;
    _userImageView.layer.backgroundColor = [[UIColor whiteColor]CGColor];

    _titleLabel.text = _playList.title;
    _titleLabel.numberOfLines = 0;
    _titleLabel.font = [UIFont systemFontOfSize:20];
    _timeLabel.text = [NSString stringWithFormat:@"%@ · %@ · %@喜欢", _playList.date_str, _playList.address, _playList.like_count];
    NSString *string = [_playList.tab_list componentsJoinedByString:@"  "];
    _typeLabel.text = string;
    _moneyLabel.text = [NSString stringWithFormat:@"￥%@", _playList.price];
    _moneyLabel.textColor = [UIColor redColor];
    _moneyLabel.font = [UIFont systemFontOfSize:25];
    _titleLabel.textColor = [UIColor whiteColor];
    _timeLabel.textColor = [UIColor whiteColor];
    _typeLabel.textColor = [UIColor whiteColor];

    
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
